package com.yazi.mxz.common.entity.beans;

import com.myframework.smhj.hibernate.Entity;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.SEQUENCE;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 * ShoppingCart entity. @author MyEclipse Persistence Tools
 */
@javax.persistence.Entity
@Table(name = "MXZ_SHOPPING_CART", schema = "HCD_DEV", uniqueConstraints = @UniqueConstraint(columnNames = {
		"MEMBER_ID", "STORE_ID" }))
public class ShoppingCart extends Entity implements java.io.Serializable {

	// Fields

	private Long cartId;
	private Member member;
	private Store store;
	private Set<Shopping> shoppings = new HashSet<Shopping>(0);

	// Constructors

	/** default constructor */
	public ShoppingCart() {
	}

	/** minimal constructor */
	public ShoppingCart(Member member, Store store) {
		this.member = member;
		this.store = store;
	}

	/** full constructor */
	public ShoppingCart(Member member, Store store, Set<Shopping> shoppings) {
		this.member = member;
		this.store = store;
		this.shoppings = shoppings;
	}

	// Property accessors
	@SequenceGenerator(name = "generator", sequenceName = "SEQ_SHOPPING_CART")
	@Id
	@GeneratedValue(strategy = SEQUENCE, generator = "generator")
	@Column(name = "CART_ID", unique = true, nullable = false, precision = 15, scale = 0)
	public Long getCartId() {
		return this.cartId;
	}

	public void setCartId(Long cartId) {
		this.cartId = cartId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "MEMBER_ID", nullable = false)
	public Member getMember() {
		return this.member;
	}

	public void setMember(Member member) {
		this.member = member;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "STORE_ID", nullable = false)
	public Store getStore() {
		return this.store;
	}

	public void setStore(Store store) {
		this.store = store;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "shoppingCart")
	public Set<Shopping> getShoppings() {
		return this.shoppings;
	}

	public void setShoppings(Set<Shopping> shoppings) {
		this.shoppings = shoppings;
	}

}